package com.mi.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.orm.hibernate5.HibernateTemplate;
import org.springframework.stereotype.Repository;

import com.mi.dao.BrandDao;
import com.mi.entity.Phonebrand;

/**
 * 跟手机品牌有关的dao
 * @author muchengxiang
 *
 */
@Repository
public class BrandDaoImpl implements BrandDao{
	
	@Resource  
	private HibernateTemplate template;

	/**
	 *  查询所有的手机品牌
	 */
	@Override
	public List<Phonebrand> getAllBrand() {
		List<Phonebrand> find = (List<Phonebrand>) template.find("from Phonebrand");
		return find;
	}

	/**
	 * 根据手机品牌名字查询该品牌的所有手机
	 */
	@SuppressWarnings("unchecked")
	@Override
	public List<Phonebrand> getByName(String brandName) {
		List<Phonebrand> find = (List<Phonebrand>) template.find("from Phonebrand where brandName=?",brandName);
		return find;
	}

}
